<?php
$i=0;
$sum = 0.00;
$ilosc_typow = 0;
$total_amount = 0.00;
$delivery_costs = 0.00;
if( isset($items) && is_array($items) && !empty($items)){
	foreach ($items as $item){
		$ilosc_typow =  $item['StoreProduct']['amount'];
		$total_amount += $ilosc_typow;
	
		if($item['StoreProduct']['price_przecena'] > 0 && $item['StoreProduct']['price_promocja'] == 0){
			$price = str_replace(',', '.', $item['StoreProduct']['price_przecena']) * $ilosc_typow;	
			$price_detal = str_replace(',', '.', $item['StoreProduct']['price_detaliczna'])*$ilosc_typow;								
			$sum += $price;
		}else if( $item['StoreProduct']['price_promocja'] > 0){
			$price = str_replace(',', '.', $item['StoreProduct']['price_promocja']) * $ilosc_typow;	
			$price_detal = str_replace(',', '.', $item['StoreProduct']['price_detaliczna'])*$ilosc_typow;								
			$sum += $price;
		}else{
			$price = str_replace(',', '.', $item['StoreProduct']['price_detaliczna']) * $ilosc_typow;									
			$sum += $price;
		}
	} 
}
// delivery
//if(isset($delivery) && is_array($delivery) && !empty($delivery)){
//	$delivery_costs = $this->Store->price($delivery['price'],2,null,null,$delivery['currency_id'],$delivery['exchange']);
//	$sum += $delivery['price'];
//} 
$total_value = $this->Store->price($sum,2,null,null,$this->Session->read('Store.selected_currency'),$this->Session->read('Store.selected_exchange'));
?>


<div id="cart-info-top-panel">
	<div id="cart-info-top-content">
		<?php echo __d('store.moon','Your Basket',true)?> &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
		<?php echo $total_amount ?> <?php echo __d('store.moon','items',true)?> &nbsp;&nbsp;|&nbsp;&nbsp;
		<?php // echo __d('store.moon','Delivery',true)?> <?php // echo $delivery_costs?> <?php //echo '&nbsp;&nbsp;|&nbsp;&nbsp;'?>
		<?php echo __d('store.moon','Total',true)?> <?php echo $total_value?> &nbsp;&nbsp;|&nbsp;&nbsp;
		<?php echo $html->link(__d("store","Checkout",true),array('plugin'=>'store','controller'=>'carts','action'=>'cart_view'),array())?> &nbsp;&nbsp;|&nbsp;&nbsp;
		<?php echo $html->link(__d("store","View",true),array('plugin'=>'store','controller'=>'carts','action'=>'cart_view'),array())?>
	</div>
</div>